package com.blog.controller;


import com.blog.common.result.R;
import com.blog.entity.po.Tag;
import com.blog.service.ITagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 * 标签 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-03-24
 */
@RestController
@RequestMapping("/tag")
public class TagController {

    @Autowired
    private ITagService tagService;

    @GetMapping
    public R<List<Tag>> getList(){
        List<Tag> list = tagService.list();
        return R.success(list);
    }



    @DeleteMapping("{id}")
    public R delById(@PathVariable String id ){
        tagService.delById(id);
        return R.success();
    }

    @PostMapping
    public R saveTag(@RequestBody Tag tag){
        tagService.saveTag(tag);
        return R.success();
    }

    @PutMapping
    public R editTag (@RequestBody Tag tag){
        tagService.editTag(tag);
        return R.success();
    }


}
